package com.jy.wms.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jy.wms.common.UUIDUtils;
import com.jy.wms.common.base.BaseService;
import com.jy.wms.dao.WmsGoodsAccessoriesMapper;
import com.jy.wms.pojo.WmsGoodsAccessories;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
    * @ClassName: WmsGoodsAccessoriesService.java
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @Author JaneLiu
    * @Date Fri Sep 08 13:52:55 CST 2017
    */

    @Service
    public class WmsGoodsAccessoriesService extends BaseService<WmsGoodsAccessoriesMapper,WmsGoodsAccessories> {

     /**
     * 插入一条记录
     * @param list 实体对象
     * @return int
     */
    public Integer baseInsert(List<WmsGoodsAccessories> list){
         return dao.baseInsert(list);
    }
        /**
         * 插入多条条记录
         * @param list 实体对象集合
         * @return int
         */
        public Integer baseInsertByMap(List<Map<String,Object>> list, String hpid){
            List<WmsGoodsAccessories> acc=new ArrayList<>();
            for(Map<String,Object> map2:list) {
                WmsGoodsAccessories accessories=new WmsGoodsAccessories();
                accessories.setId(UUIDUtils.uuid());
                accessories.setHpid(map2.get("hpid").toString());
                accessories.setSl(map2.get("sl").toString());
                accessories.setSshpid(hpid);
                accessories.setCkid(map2.get("ckid").toString());
                acc.add(accessories);
            }
            return dao.baseInsert(acc);
        }

   /**
    * 插入一条记录（匹配有值的字段）
    * @param entity 实体对象
    * @return int
    */
    public Integer baseInsertSelective(WmsGoodsAccessories entity){
         return dao.baseInsertSelective( entity);
    }

   /**
    * 删除（根据主键ID删除）
    * @param id 主键
    * @return int
    */
    public Integer baseDeleteByPrimaryKey(String id){
         return dao.baseDeleteByPrimaryKey( id);
    }

   /**
    * 删除（根据ID 批量删除）
    * @param idList 主键ID列表
    * @return int
    */
    public Integer baseDeleteBathPrimaryKeys(List<String> idList){
         return dao.baseDeleteBathPrimaryKeys( idList);
    }

    /**
    * 分页查询
    * @param entity 实体
    * @return Page<WmsGoodsAccessories>
    */
    public Page<WmsGoodsAccessories> baseSelectPage(WmsGoodsAccessories entity){
        PageHelper.startPage(entity.getPage(),entity.getRows());
        return (Page<WmsGoodsAccessories>)dao.baseSelectPage( entity);
    }

   /**
    * 查询（根据主键ID查询）
    * @param id 主键ID
    * @return WmsGoodsAccessories
    */
    public WmsGoodsAccessories baseSelectByPrimaryKey(String id){
         return dao.baseSelectByPrimaryKey( id);
    }

   /**
    * 查询（根据ID 批量查询）
    * @param idList 主键ID列表
    * @return list
    */
    public Integer baseSelectBathPrimaryKeys(List<WmsGoodsAccessories> idList){
         return dao.baseSelectBathPrimaryKeys( idList);
    }

   /**
    *修改 （匹配有值的字段）
    * @param entity 主键ID列表
    * @return int
    */
    public Integer baseUpdateByPrimaryKeySelective(WmsGoodsAccessories entity){
         return dao.baseUpdateByPrimaryKeySelective( entity);
    }

   /**
    *修改（根据主键ID修改）
    * @param entity 主键ID列表
    * @return int
    */
    public Integer baseUpdateByPrimaryKey(WmsGoodsAccessories entity){
         return dao.baseUpdateByPrimaryKey( entity);
    }
        /**
         * 删除（根据所属货品ID删除）
         * @param sshpid 主键
         * @return int
         */
        public Integer baseDeleteBySshpid(@Param("sshpid") String sshpid){
            return  dao.baseDeleteBySshpid(sshpid);
        }
    /**
     * 查询（根据货品ID查询）
     * @param sshpid 货品ID
     * @return User
     */
    public List<WmsGoodsAccessories> baseSelectBySshpid(@Param("sshpid") String sshpid){
        return dao.baseSelectBySshpid(sshpid);
    }
}
